

package bookings;

import java.util.HashSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;


public class ShoppingCart {
    
    public ShoppingCart() {
    }
    
    public String execute() throws Exception {
        String result="success";
        
        HttpServletRequest request=ServletActionContext.getRequest();  
        HttpSession session=request.getSession();
        HashSet<bookings.CartItem> cart=(HashSet<bookings.CartItem>)session.getAttribute("Cart");
        double total=0;
        for(bookings.CartItem ci : cart)
            total+=ci.getSubTotal();
        
        request.setAttribute("total", total);
        
        return result;
    }
    
}
